package top.eggcode.modules.user.service;

import lombok.RequiredArgsConstructor;
import org.apache.shiro.authc.ExpiredCredentialsException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.springframework.stereotype.Service;
import top.eggcode.security.shiro.SessionTokenUtil;

/**
 * Title:
 * Description: TODO
 * Date: 2021/7/28 21:13
 *
 * @author JiaQi Ding
 * @version 1.0
 */
@RequiredArgsConstructor
@Service
public class AuthService {

    /**
     * 未开发完成
     *
     * @param token 会话令牌
     * @return 令牌
     */
    public String refreshToken(String token) {
        // token 过期
        if (SessionTokenUtil.overdue(token)) {
            throw new ExpiredCredentialsException("token 过期");
        }

        // 无效token
        if (!SessionTokenUtil.verify(token)) {
            throw new IncorrectCredentialsException("无效 token");
        }

        return "";
    }


}
